home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
tools
/
classdoc.lha
/
classdoc
/
diagram.H
< prev
next >
Wrap
C/C++ Source or Header
|
1993-08-08
|
3KB
|
117 lines
// Diagram is a class for drawing multiple plots in InterViews.
// The axes of a diagram may be provided with tic marks or a grid.
// The spacing between tic mark labels is determined automatically.
//
// Note that the diagram is not automatically redrawn at every change
// to the plots, in particular not when points are added to the plots.
// Method Draw() will redraw the diagram.
//
// Author: Dag Bruck, Department of Automatic Control, Lund Institute of
// Technology, Box 118, S-221 00 Lund, Sweden.
// Last revision: 1989-04-18.
#ifndef DIAGRAM_H
#define DIAGRAM_H
#include <InterViews/interactor.h>
class PlotRep;
class Diagram : public Interactor {
public:
Diagram(const char* heading = nil);
Diagram(const char* heading, Coord width, Coord height);
// Creates new Diagram; default dimension 12x8 cm. The heading is stored
// as the instance name, and can be accessed with method GetInstance().
void SetHeading(const char *);
// Sets new heading (cannot be nil).
virtual void Limits(float xlow, float xhigh, float ylow, float yhigh);
// Defines lower and upper limits of the plot area. The initial plot
// area ranges from (0, 0) to (1, 1).
// Plots are scaled to fit available space.
virtual void Tic(float xstart, float xinc, float ystart, float yinc);
// Determines position of tic marks on axes. An increment of 0
// means that the axis is not labeled. Initially, no tic marks are shown.
virtual void Grid(boolean);
// Controls drawing of grid.
virtual void Begin(int size = 200, Painter* = nil);
// Starts a new plot in this diagram, accepting maximum `size' points.
virtual void Plot(float x, float y);
// Adds point to "current" plot. The diagram is not automatically
// redrawn; use method Draw().
virtual void Polyline(int n, float x[], float y[], Painter* = nil);
// Defines new plot with given contents. The diagram is not redrawn.
void Redraw(Coord, Coord, Coord, Coord);
void Reconfig();
void Resize();
// Routines declared in class Interactor.
protected:
float xll, xul, yll, yul;
// Upper and lower limits of plot.
float xscale, yscale;
Coord xoffset, yoffset;
// For transforming user's coordinates to screen coordinates.
float xstart, xinc, ystart, yinc;
// Controls position of tic marks.
float xnumstart, xnuminc, ynumstart, ynuminc;
// Controls position of tic mark labels.
PlotRep* first;
// List of plotted curves.
char* labelformat;
// Printf(3) format string used for tic mark labels.
// The initial value is "%.4G".
boolean grid;
// Draw grid or not?
Coord Xmap(float), Ymap(float);
// Maps user coordinate to screen coordinate used by InterViews.
Coord NumWidth(float);
// Returns width of number using label format string.
Coord NumIntWidth(float);
// Returns width of integer part of number using label format string.
virtual void PlotArea();
// Computes scale and offset of plot area, taking into account
// space for labels and axes tics. Increments between labeled tic marks
// are also calculated.
virtual void DrawAxes();
// Draws axes and heading of diagram.
private:
void Init(const char*);
// Initializes of Diagram object.
};
inline Coord Diagram :: Xmap(float x)
{ return Coord((x - xll) * xscale) + xoffset; }
inline Coord Diagram :: Ymap(float y)
{ return Coord((y - yll) * yscale) + yoffset; }
#endif